package main

import (
	"fmt"
	"runtime"
	"time"
)

/*
Goexit() 退出当前协程
*/
func main() {
	go func() {
		defer fmt.Println("A.defer")
		func() {
			defer fmt.Println("B.defer")
			// 结束协程
			runtime.Goexit()
			defer fmt.Println("C.defer")
			fmt.Println("B")
		}()
		fmt.Println("A")
	}()
	time.Sleep(10 * time.Second)
	/*
		最后仅打印
		B.defer
		A.defer
	*/
}
